// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

@use "refactor/common-refactor.scss" as deprecated;
@use "ds/_sizes.scss" as *;
@use "ds/_borders.scss" as *;
@use "ds/_utils.scss" as *;
@use "ds/z-index.scss" as *;
@use "ds/typography.scss" as t;
@use "ds/mixins.scss" as *;

// Library modal
.modal-overlay {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  z-index: var(--z-index-set);
  background-color: var(--overlay-color);
}

.modal-dialog {
  position: relative;
  padding: var(--sp-xxxl);
  border-radius: $br-8;
  background-color: var(--modal-background-color);
  border: $b-2 solid var(--modal-border-color);
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: $sz-364;
  min-height: $sz-192;
  height: $sz-520;
  max-height: $sz-520;
  width: $sz-712;
  max-width: $sz-712;
}

// TODO: Remove this extended creating modal component
.close-btn {
  @extend .modal-close-btn-base;
}

.close-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  height: $sz-16;
  width: $sz-16;
  color: transparent;
  fill: none;
  stroke-width: $b-1;
  stroke: var(--icon-foreground);
}

.modal-title {
  @include t.use-typography("headline-medium");
  margin-block-end: var(--sp-l);
  color: var(--color-foreground-primary);
}

// Tabs content
.libraries-content,
.updates-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-xxxl);
  max-height: $sz-400;
  padding-block-start: var(--sp-l);
}

.lib-section,
.update-section,
.shared-section {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--sp-s);

  .section-list {
    .section-list-item:first-child {
      border: none;
    }
  }
}

.shared-section {
  grid-template-rows: auto auto 1fr;
  row-gap: var(--sp-l);
}

.title-spacing-lib {
  margin: 0 0 0 calc(-1 * var(--sp-s));
}

.section-list,
.section-list-shared {
  display: grid;
  grid-auto-rows: min-content;
  gap: var(--sp-s);
  max-height: px2rem(320);
  overflow-y: auto;
}

.section-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-s);
  border: $b-1 solid var(--color-background-quaternary);
  padding: var(--sp-s) var(--sp-s) var(--sp-m) var(--sp-m);
  border-radius: $br-8;
}

.item-content {
  height: fit-content;
}

.item-publish,
.item-unpublish {
  // TODO: remove this extended by using DS button component
  @extend .button-primary;
  @include t.use-typography("headline-small");
  height: $sz-32;
  min-width: px2rem(92);
  padding: var(--sp-s) var(--sp-xxl);
  margin: 0;
  border-radius: $br-8;
}

.item-unpublish {
  // TODO: remove this extended by using DS button component
  @extend .button-secondary;
}

.item-button,
.item-button-shared {
  // TODO: remove this extended by using DS button component
  @extend .button-secondary;
  height: $sz-32;
  width: $sz-32;
  margin-inline-start: var(--sp-xxs);
  padding: var(--sp-s);
}

.detach-icon,
.add-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  height: $sz-16;
  width: $sz-16;
  color: transparent;
  fill: none;
  stroke-width: $b-1;
  stroke: var(--icon-foreground);
}

.section-list-shared {
  max-height: px2rem(272);
}

.section-title {
  @include t.use-typography("headline-small");
  margin-block-end: var(--sp-m);
  color: var(--title-foreground-color);
}

.search-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: px2rem(20);
  padding: 0 0 0 var(--sp-s);

  svg {
    display: flex;
    justify-content: center;
    align-items: center;
    color: transparent;
    fill: none;
    height: px2rem(12);
    width: px2rem(12);
    stroke-width: 1.33px;
    stroke: var(--icon-foreground);
  }
}

// empty state
.section-list-empty {
  @include t.use-typography("body-medium");
  display: grid;
  grid-template-rows: auto 1fr;
  justify-items: center;
  gap: var(--sp-s);
  text-align: center;
  height: fit-content;
  margin-block: var(--sp-l);
  color: var(--modal-title-foreground-color);
}

.empty-state-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: $sz-48;
  height: $sz-48;
  border-radius: $br-circle;
  background-color: var(--pill-background-color);
}

.library-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  color: transparent;
  fill: none;
  stroke-width: $b-1;
  stroke: var(--icon-foreground);
  height: $sz-32;
  width: $sz-32;
}

// Update library tab
.libraries-updates-see-all {
  @extend .link;
  direction: rtl;
  grid-column: span 3;
  margin-block-start: var(--sp-s);
  margin-inline-start: var(--sp-s);
  margin: 0;
}

.updates-content {
  grid-template-columns: 1fr;
}

.libraries-updates {
  display: grid;
  grid-column: span 3;
  grid-template-columns: repeat(auto-fill, minmax(px2rem(160), 1fr));
  gap: deprecated.$s-24;
  margin-block-start: var(--sp-l);
}

.libraries-updates-column {
  display: grid;
  gap: var(--sp-xs);
}

.libraries-updates-item {
  @include deprecated.bodyLargeTypography;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--sp-s);
  color: var(--library-content-foreground-color);
}

.component-svg {
  background-color: var(--color-canvas);
  border-radius: $br-4;
  border: $b-2 solid transparent;
  height: $sz-24;
  width: $sz-24;
  min-height: $sz-24;
  min-width: $sz-24;
}

.name-block {
  color: var(--library-content-foreground-color);
  width: px2rem(168);
}

.ellipsis {
  padding-inline-start: calc(var(--sp-xxl) + var(--sp-s));
}

.item-name {
  @include t.use-typography("body-large");
  @include textEllipsis;
  margin: 0;
  max-width: px2rem(216);
  color: var(--library-name-foreground-color);
}

.item-update {
  @extend .button-primary;
  @include t.use-typography("headline-small");
  height: $sz-32;
  min-width: px2rem(92);
  padding: var(--sp-s) var(--sp-xxl);
  margin-inline-end: var(--sp-xxs);
  border-radius: $br-8;

  &:disabled {
    @extend .button-disabled;
  }
}

.item-contents {
  @include t.use-typography("body-small");
  color: var(--library-content-foreground-color);
  display: flex;
  flex-wrap: wrap;
  margin: 0;
}

.element-count {
  white-space: nowrap;

  &:not(:last-child)::after {
    content: "·";
    margin-inline: var(--sp-xs);
  }
}

.connected-to-wrapper {
  display: block;
}

.connected-to-values {
  color: var(--color-foreground-primary);
}

// Modal Component v2 update
.modal-v2-info {
  width: px2rem(664);
  height: fit-content;
  max-height: fit-content;
}

.modal-v2-title {
  @include t.use-typography("headline-medium");
  color: var(--modal-title-foreground-color);
}

.info-content {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  margin-top: var(--sp-xxxl);
  gap: var(--sp-xxl);
}

.info-block {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--sp-xl);
  grid-template:
    "icon title"
    "icon content";
}

.info-icon {
  grid-area: icon;
  width: px2rem(52);
  height: px2rem(52);
  margin-top: var(--sp-s);
  border-radius: $br-circle;
  background: var(--color-background-quaternary);
  display: flex;
  justify-content: center;
  align-items: center;

  svg {
    width: $sz-32;
    height: $sz-32;
    fill: var(--icon-foreground-active);
  }
}

.info-block-title {
  @include t.use-typography("body-large");
  grid-area: title;
  color: var(--modal-title-foreground-color);
}

.info-block-content {
  @include t.use-typography("body-medium");
  grid-area: content;
  color: var(--library-content-foreground-color);
}

.info-bottom {
  display: flex;
  justify-content: flex-end;
  margin-block-start: var(--sp-xxl);
  margin-inline-end: var(--sp-s);
}

.primary-button {
  @extend .button-primary;
  @include t.use-typography("headline-small");
  padding: 0 var(--sp-l);
}

.sample-libraries-info {
  @include t.use-typography("body-small");
  display: flex;
  flex-direction: column;
  margin: var(--sp-xxxl);
  color: var(--color-foreground-secondary);
}

.sample-libraries-link {
  @include t.use-typography("body-small");
  color: var(--color-accent-primary);

  &:hover {
    text-decoration: underline;
  }
}

.sample-libraries-container {
  @include t.use-typography("body-small");
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: start;
  color: var(--color-foreground-secondary);
}

.sample-library-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: var(--sp-s);
}

.sample-library-item-name {
  @include t.use-typography("body-medium");
  color: var(--color-foreground-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: px2rem(232);
}

// TODO: Remove this extended using a DS component
.sample-library-add {
  @extend .button-secondary;
}

// TODO: Remove this extended using a DS component
.sample-library-adding {
  @extend .button-disabled;
}

.sample-library-button {
  @include t.use-typography("headline-small");
  height: $sz-32;
  width: px2rem(80);
  margin: 0;
  border-radius: $br-8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
